//
//  HomePage_Collection_Cell.m
//  Food
//
//  Created by dllo on 15/7/13.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "HomePage_Collection_Cell.h"

@implementation HomePage_Collection_Cell

- (void)dealloc
{
    [_view release];
    [_imageView release];
    [_lable release];
    [super dealloc];
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.view = [[UIView alloc] init];
        [self.contentView addSubview:self.view];
        
        self.imageView = [[UIImageView alloc] init];
        [self.view addSubview:self.imageView];
        
        self.lable = [[UILabel alloc] init];
        self.lable.font = [UIFont systemFontOfSize:13];
        [self.lable setTextAlignment:NSTextAlignmentCenter];
        [self.view addSubview:self.lable];
    }
    return self;
}


-(void)applyLayoutAttributes:(UICollectionViewLayoutAttributes *)layoutAttributes
{
    [super applyLayoutAttributes:layoutAttributes];
    
    self.view.frame = CGRectMake(0, 0, layoutAttributes.frame.size.width, layoutAttributes.frame.size.height);
    
    self.imageView.frame = CGRectMake(0, 0, self.view.frame.size.height - 20, self.view.frame.size.height - 20);
    self.imageView.center = CGPointMake(self.view.frame.size.width / 2.0, self.imageView.frame.size.height / 2.0);
    [self.imageView.layer setCornerRadius:self.imageView.frame.size.width / 2.0];
    [self.imageView setClipsToBounds:YES];
    self.lable.frame = CGRectMake(0, self.imageView.frame.size.height, self.view.frame.size.width, 20);
}

@end
